<template>
  <h1>这是子组件，名字叫{{ name }}</h1>
  <p>父组件给子组件传的值是————>{{ msg }}——{{ status }}</p>
  <van-switch v-model="checked" />
  <button type="button" @click="toFather">
    向父组件传值
  </button>
</template>

<script setup> 
import {ref,getCurrentInstance} from "vue"; 

const vm = getCurrentInstance()
const name = ref('李四') 
  const checked = ref(true);
const props = defineProps({
  msg: String, 
  status: { type: String, required: false, default: '未定义', },
})
// 定义事件(子组件向父组件传参)
const emit = defineEmit(['toFather']);
const toFather = () => { 
  name.value =" 张氏 "
  checked.value = false
  realtoFather()
}

const realtoFather = () => {  
  console.log(vm.appContext.config.globalProperties.get) // 由这写法还不如直接引 get post 呢
   
  emit('toFather', '112233');
}
</script>

<style scoped>

</style>
